package main

import (
	"fmt"
	"net/http"
	"time"
)

// go内置的http
func main() {

	http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(rw, "Hello go")
	})

	// 最长前缀匹配
	http.HandleFunc("/time", func(rw http.ResponseWriter, r *http.Request) {
		t := time.Now()
		tstr := fmt.Sprintf("{\"time\" : \"%s\"}", t)
		rw.Write([]byte(tstr))
	})

	http.ListenAndServe(":8080", nil)
}
